package edu.nf.admin.controller.admin;

import edu.nf.waimai.dao.admin.impl.AdminRiderDaoImpl;
import edu.nf.waimai.model.rider.Rider;
import org.nf.web.annotation.Model;
import org.nf.web.annotation.RequestMapping;
import org.nf.web.annotation.RequestParam;
import org.nf.web.servlet.View;
import org.nf.web.servlet.view.JsonView;

import java.util.List;

/**
 * @Date 2023-09-12
 * @Author qiu
 * 骑手信息
 */
public class RiderInfoController extends BaseController {


    /**
     * 骑手信息 -- 管理员端
     *
     * @return
     */
    @RequestMapping("/rider/riderInfo")
    public View getAllRider() {
        List<Rider> allRider = new AdminRiderDaoImpl().getAllRider();
        return new JsonView(success(allRider));
    }


    /**
     * 骑手修改
     *
     * @param rider
     * @return
     */
    @RequestMapping("/rider/updateRider")
    public View updateRider(@Model Rider rider) {
        int i = new AdminRiderDaoImpl().updateRider(rider);
        return new JsonView(success(200, "修改成功", i));
    }

    /**
     * 删除骑手
     *
     * @param rid
     * @return
     */
    @RequestMapping("/rider/deleteRider")
    public View deleteRider(@RequestParam("riderId") int rid) {
        int i = new AdminRiderDaoImpl().deleteRider(rid);
        return new JsonView(success(200, "删除成功", i));
    }

    /**
     * 添加骑手
     *
     * @param rider
     * @return
     */
    @RequestMapping("/rider/addRider")
    public View addRider(@Model Rider rider) {
        int i = new AdminRiderDaoImpl().addRider(rider);
        return new JsonView(success(200, "添加成功", i));
    }

    /**
     * 查询商家订单信息
     *
     * @return
     */
    @RequestMapping("/rider/getRider")
    public View getRider() {
        List<Rider> rider = new AdminRiderDaoImpl().getRider();
        return new JsonView(success(rider));
    }

}
